import { IPSCodeList } from '../codelist/ipscode-list';
import { IPSDataItem } from './ipsdata-item';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSDataItemImpl extends PSModelObjectImpl implements IPSDataItem {
  get codeName(): string {
    return this.M.codeName;
  }

  get dataType(): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 {
    return this.M.dataType;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get format(): string {
    return this.M.format;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pscodelist: IPSCodeList | null = null;

  getPSCodeList(): IPSCodeList | null {
    if (this.pscodelist != null) return this.pscodelist;
    const value = this.M.getPSCodeList;
    if (value == null) {
      return null;
    }
    this.pscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getPSCodeList') as IPSCodeList;
    return this.pscodelist;
  }

  get psCodeList(): IPSCodeList | null {
    return this.getPSCodeList();
  }

  getPSCodeListMust(): IPSCodeList {
    const value = this.getPSCodeList();
    if (value == null) {
      throw new Error('未指定代码表对象');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get convertToCodeItemText(): boolean {
    return this.M.convertToCodeItemText != null ? this.M.convertToCodeItemText : false;
  }

  get cls(): string {
    return 'PSDataItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelObject' || cls == 'IPSObject' || cls == 'data.IPSDataItem') return true;
    return super.instanceof(cls);
  }
}
